package com.jiajia.study.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: RabbitConfig
 * @Author zjj
 * @Package com.jiajia.study.config
 * @Date 2024/3/8 12:31
 * @description:
 */

@Configuration
public class RabbitConfig {

    @Bean
    public TopicExchange topicExchange(){
        return ExchangeBuilder.topicExchange("topic.exchange.a").build();
    }

    @Bean
    public Queue queueA(){
        return QueueBuilder.durable("topic.queue.a").build();
    }

    @Bean
    public Queue queueB(){
        return QueueBuilder.durable("topic.queue.b").build();
    }

    @Bean
    public Queue queueC(){
        return QueueBuilder.durable("topic.queue.c").build();
    }

    @Bean
    public Queue queueD(){
        return QueueBuilder.durable("topic.queue.d").build();
    }

    @Bean
    public Binding bindingA(Queue queueA,TopicExchange topicExchange){
        return BindingBuilder.bind(queueA).to(topicExchange).with("*.orange.*");
    }

    @Bean
    public Binding bindingB(Queue queueB,TopicExchange topicExchange){
        return BindingBuilder.bind(queueB).to(topicExchange).with("*.*.rabbit");
    }

    @Bean
    public Binding bindingC(Queue queueC,TopicExchange topicExchange){
        return BindingBuilder.bind(queueC).to(topicExchange).with("lazy.y.#");
    }

    @Bean
    public Binding bindingD(Queue queueD,TopicExchange topicExchange){
        return BindingBuilder.bind(queueD).to(topicExchange).with("#.lazy");
    }


}
